package DP.Medium;

import java.util.Arrays;

public class LC0300 {
    public int lengthOfLIS(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n]; // dp[i]表示以nums[i]为最后一个数字的子序列的最长长度
        Arrays.fill(dp, 1);
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[j] < nums[i]) dp[i] = Math.max(dp[i], dp[j] + 1);
            }
        }

        int maxLength = dp[0];
        for (int i = 1; i < n; i++) maxLength = Math.max(maxLength, dp[i]);
        return maxLength;
    }
}
